package com.gitee.chili.leisure.exception;

import com.gitee.chili.leisure.ResponseCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * BusinessException
 *
 * @author week solider
 * @version v1.0
 * @since 2019/12/10
 */

@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

    private Integer code;
    private String message;

    public BusinessException() {
        super();
        this.code = 500;
        this.message = "请求失败";
    }

    public BusinessException(String message) {
        super(message);
        this.code = 500;
        this.message = message;
    }

    public BusinessException(ResponseCode code) {
        super(code.getValue());
        this.code = code.getCode();
        this.message = code.getValue();
    }

    public BusinessException(String message, Throwable cause) {
        super(message, cause);
        this.code = ResponseCode.FAIL.getCode();
        this.message = message;
    }

    public BusinessException(Throwable cause) {
        super(cause);
        this.code = ResponseCode.FAIL.getCode();
        this.message = ResponseCode.FAIL.getValue();
    }

}
